module.exports = function(router){
  let User = require('./models.js')["User"];
  router.get('/users/:id', function(ctx, next) {
      return User.findById(ctx.params.id).then(function(user) {
          ctx.user = user;
          if (!user) {
              ctx.status = "404";
          }
          // session test
          ctx.session.views = ctx.session.views?ctx.session.views+1:1;
          //console.log(ctx.session);
          return next();
      });
  }, function(ctx) {

      ctx.body = ctx.user.firstName
  });

}
